/**
 * ...
 * @author Krzysztof Rozalski
 */

package hapi.physics.integration;
import hapi.physics.Acceleration;
import hapi.physics.AngularAcceleration;
import hapi.physics.AngularVelocity;
import hapi.physics.Force;
import hapi.physics.Time;
import hapi.physics.Velocity;

class Derivative {
	
	public var velocity:Velocity;
	public var acceleration:Acceleration;
	public var angularVelocity:AngularVelocity;
	public var angularAcceleration:AngularAcceleration;
	
	public function new(target:Integrateable, delta:Time, accelerator:Accelerator) {
		this.velocity = target.velocity.clone();
		this.angularVelocity = target.angularVelocity.clone();
		
		this.acceleration = accelerator.acceleration(target, delta);
		this.angularAcceleration = accelerator.angularAcceleration(target, delta);
	}
	
	public function applyTo(target:Integrateable, delta:Time):Void {
		velocity.applyTo(target.position, delta);
		acceleration.applyTo(target.velocity, delta);
		angularVelocity.applyTo(target.angle, delta);
		angularAcceleration.applyTo(target.angularVelocity, delta);
	}
}